<template>
    <div>
        <div v-for="(item, index) in phone">
            <div class="small_box" @click="cli(index)">
                <img :src="item.picurl" width="150px" height="150px">
                <p>{{ item.name }}</p>
                <p><span>¥{{ item.price }}</span><span>起</span><span>看相似</span></p>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            phone: [{
                name: '小米11',
                price: 5999,
                picurl:require('../img/1.jpg')
            }, {
                name: '插头',
                price: 49,
                picurl:require('../img/1.jpg')
            }, {
                name: '小身材大智慧',
                price: 49,
                picurl:require('../img/1.jpg')
            }, {
                name: 'Redmi Note 9 4G',
                price: 999,
                picurl:require('../img/1.jpg')
            }, {
                name: '青年“无须”选择',
                price: 99,
                picurl:require('../img/1.jpg')
            }, {
                name: '全面屏更多可能',
                price: 229,
                picurl:require('../img/1.jpg')
            }]
        }
    },
    methods: {
        cli(index) {
            let title = this.phone[index].name;
            this.$emit('cli', title);
        }
    }
}
</script>

<style scoped>
.big_box {
    width: 45%;
    height: 960px;
    border: 2px solid red;
    margin: auto;
    background-color: white;
    background-color: #cccc;
}

.small_box {
    border-radius: 10px;
    width: 45%;
    height: 250px;
    margin: 9px;
    background-color: white;
}

.small_box:nth-child(odd) {
    float: left;
}

.small_box img {
    display: block;
    margin: 20px auto;
}

.small_box p {
    text-align: center;
}

.small_box p:nth-child(3) span:nth-child(1) {
    color: red;
    font-size: 20px;
}

.small_box p:nth-child(3) span:nth-child(2) {
    color: red;
}

.small_box p span:nth-child(3) {
    border: 1px solid gray;
    border-radius: 5px;
    color: gray;
    margin-left: 20%;
}
</style>